package com.fun.library.core;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;

import java.io.InputStream;

/**
 * 作者: Created by AdminFun
 * 邮箱: 614484070@qq.com
 * 创建: 2018/12/24
 * 修改: 2018/12/24
 * 版本: v1.0.0
 * 描述: 自定义BitmapDrawable，实现Image在HTML中正常显示（系统的BitmapDrawable显示在HTML中是缩小的）
 */
public class HtmlDrawable extends BitmapDrawable {

    public HtmlDrawable(Bitmap bitmap) {
        super(bitmap);
    }

    public HtmlDrawable(Resources res, Bitmap mBitmap) {
        super(res, mBitmap);
    }

    public HtmlDrawable(String filepath) {
        super(filepath);
    }

    public HtmlDrawable(Resources res, String filepath) {
        super(res, filepath);
    }

    public HtmlDrawable(InputStream is) {
        super(is);
    }

    public HtmlDrawable(Resources res, InputStream is) {
        super(res, is);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
       Bitmap mBitmap =  getBitmap();
        if (mBitmap != null && !mBitmap.isRecycled()) {
            canvas.drawBitmap(mBitmap, 0, 0, getPaint());
        }
    }
}